package com.hospital.serviceImpl;

import com.hospital.dao.RoleMapper;
import com.hospital.entity.Role;
import com.hospital.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;

    /**
     * 查所有角色
     *
     * @return 集合中的角色信息
     */
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<Role> SelectAll() {
        List<Role> roles = roleMapper.SelectAll();
        return roles;
    }

    /**
     * 批量删除用户
     *
     * @param id 用户id
     * @return 删除状态
     */
    @Override
    public int BulkDelete(List<Integer> id) {
        int state = roleMapper.BulkDelete(id);
        return state;
    }


    /**
     * 添加角色方法
     *
     * @param role 角色对象
     * @return 添加状态
     */
    @Override
    public Integer Insert(Role role) {
        Integer state = roleMapper.Insert(role);
        return state;
    }
}
